﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufInterface.h"

namespace gnuf
{
    // 暂时没考虑产品DB调用的问题（以后有需要，再将这个接口移动到BuNewUiFrameworkInterface）
    class GNUF_INTERFACE_EXPORT CommonDialogInterface
    {
    public:
        static CommonDialogInterface* Get();

        // 显示打开文件对话框，并返回选中的单个文件
        static std::wstring OpenFileDialog(const std::wstring& caption, const std::wstring& initialPath, const std::wstring& filter, int filterIndex = -1, bool directoryOnlyFlag = false);
        // 显示打开文件对话框，并返回选中的多个文件
        static std::vector<std::wstring> OpenFilesDialog(const std::wstring& caption, const std::wstring& initialPath, const std::wstring& filter, int filterIndex = -1);

        /// \brief 打开一个用于选择文件保存路径的对话框
        ///
        /// \param[in] caption 对话框的Title
        /// \param[in] initialPath 默认打开的路径
        /// \param[in] filter 文件类型过滤规则，如GBMP_TR(L"DXF文件(*.dxf)")
        /// \param[in] title 需要在对话框中选中的文件的文件名
        /// \return 文件保存路径
        static std::wstring SaveFileDialog(const std::wstring& caption, const std::wstring& initialPath, const std::wstring& filter, const std::wstring& title = L"");

        /// \brief 打开一个用于选择文件保存路径的对话框
        ///
        /// \param[in] caption 对话框的Title
        /// \param[in] initialPath 默认打开的路径
        /// \param[in] filter 文件类型过滤规则，如GBMP_TR(L"DXF文件(*.dxf)")
        /// \param[in] title 需要在对话框中选中的文件的文件名
        /// \param[out] selectFilter 文件类型过滤器中选中的过滤规则 如GBMP_TR(L"DXF文件(*.dxf)")
        /// \return 文件保存路径
        static std::wstring SaveFileDialog(const std::wstring& caption, const std::wstring& initialPath, const std::wstring& filter, const std::wstring& title, std::wstring& selectFilter);

    protected:
        // 显示打开文件对话框，并返回选中的单个文件
        virtual std::wstring ShowOpenFileDialog(const std::wstring& caption, const std::wstring& initialPath, const std::wstring& filter, int filterIndex = -1, bool directoryOnlyFlag = false) = 0;
        // 显示打开文件对话框，并返回选中的多个文件
        virtual std::vector<std::wstring> ShowOpenFilesDialog(const std::wstring& caption, const std::wstring& initialPath, const std::wstring& filter, int filterIndex = -1) = 0;
        /// \brief 打开一个用于选择文件保存路径的对话框
        virtual std::wstring ShowSaveFileDialog(const std::wstring& caption, const std::wstring& initialPath, const std::wstring& filter, const std::wstring& title = L"") = 0;
        /// \brief 打开一个用于选择文件保存路径的对话框
        virtual std::wstring ShowSaveFileDialog(const std::wstring& caption, const std::wstring& initialPath, const std::wstring& filter, const std::wstring& title, std::wstring* selectedFilter) = 0;

    protected:
        CommonDialogInterface() {}

        // 此接口由UI框架调用，外部不可调用。
        // 如必须调用，请联系jianggy-a@glodon.com
        void SetInterface(CommonDialogInterface*);

    private:
        CommonDialogInterface(const CommonDialogInterface&) = delete;
        CommonDialogInterface(CommonDialogInterface&&) = delete;
        CommonDialogInterface& operator=(const CommonDialogInterface&) = delete;
    };
}
